package com.ztjy.sys.controller;

import com.github.pagehelper.PageInfo;
import com.ztjy.bean.Journal;
import com.ztjy.bean.LogParams;
import com.ztjy.sys.biz.SysLogBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.context.request.WebRequest;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.List;

/**
 * 日志管理
 */
@RequestMapping("/sys/logs")
@Controller
public class LogController {
    @Autowired
    private SysLogBiz sysLogBiz;

    @RequestMapping("/logList")
    public String allLogs(LogParams logParams, Model model, @RequestParam(value = "pageno", defaultValue = "1") Integer pageNo) {
        Integer pageSize = 6;
        PageInfo<Journal> logpage = sysLogBiz.findAllLogs(logParams, pageNo, pageSize);
        model.addAttribute("logInfo", logpage);
        model.addAttribute("logParams", logParams);
        return "/sys/logs/logList";
    }

    @RequestMapping("/dateils/{jId}")
    public String dateils(@PathVariable("jId")Integer jId,Model model){
        Journal journal = sysLogBiz.detailsLogs(jId);
        model.addAttribute("journal",journal);
        return "forward:/sys/logs/logView.html";
    }
}
